{% extends "base.html" %}

{% load tags %}

{% block title %}post list {% endblock %}

{% block body-title %} <h1>post list</h1> {% endblock %}
{% block style %}

.table_border
{
border:1px solid black;
border-collapse:collapse;
width:100%;
caption-side:top;
}

.table_border td
{
border:1px solid black;
border-collapse:uncollapse;
word-wrap:break-word;
overflow:hidden;
padding:15px;
}
.table_noborder
{
border:0px;
width:100%;
border-collapse:separate;
border-spacing:0px 0px;
table-layout:automatic;
}

.table_noborder td
{
border:0px;
word-wrap:break-word;
overflow:hidden;
padding:5px;
text-align:left;
vertical-align:top;
}

table
{
border:1px solid black;
border-collapse:collapse;
width:100%;
}
th,td
{
border:1px solid black;
border-collapse:collapse;
word-wrap:break-word;
overflow:hidden;
}
{% endblock %}

{% block content %}
<fieldset>
<legend>选项</legend>
<form action="" method="GET">
<table class="table_noborder" >
<tr>
<td width="20%">
<b>论坛：</b>
{% for sector in sectors %} <br/>
<input type="checkbox" name="kind" value="{{sector.id}}" {%if sector in kind%}checked="checked"{% endif %} id="sector_{{sector.id}}" ><label for="sector_{{sector.id}}">{{ sector.name }}</label></input>
{% endfor %}
</td>
<td width="10%">
<b>类型：</b> <br/>
<input type="radio" name="datetype" {%ifequal upd_or_crt|lower "crt"%}checked="checked"{%endifequal%} value="crt" id="datetype_crt"> <label for="datetype_crt" >最后发表 </label><br/>
<input type="radio" name="datetype" {%ifequal upd_or_crt|lower "upd"%}checked="checked"{%endifequal%} value="upd" id="datetype_upd"> <label for="datetype_upd">最后回复</label>
</td>
<td width="10%">
<b>天数：</b>
<br/>
<select name="since">
<option value="1"  {%ifequal since 1 %}selected="selected"{%endifequal%}>一天内</option>
<option value="3"  {%ifequal since 3 %}selected="selected"{%endifequal%}>三天内</option>
<option value="5"  {%ifequal since 5 %}selected="selected"{%endifequal%}>五天内</option>
<option value="10" {%ifequal since 10 %}selected="selected"{%endifequal%}>十天内</option>
<option value="30" {%ifequal since 30 %}selected="selected"{%endifequal%}>三十天内</option>
<option value="0" {%ifequal since 0 %}selected="selected"{%endifequal%}>无限制</option>
</select>
<br/>
<b>数量限制：</b> <br/>
<select name="limit">
<option value="0"    {%ifequal limit 0%}selected="selected"{%endifequal%}>无限制</option>
<option value="20"   {%ifequal limit 20%}selected="selected"{%endifequal%}>20条</option>
<option value="50"   {%ifequal limit 50%}selected="selected"{%endifequal%}>50条</option>
<option value="100"  {%ifequal limit 100%}selected="selected"{%endifequal%}>100条</option>
<option value="300"  {%ifequal limit 300%}selected="selected"{%endifequal%}>300条</option>
<option value="500"  {%ifequal limit 500%}selected="selected"{%endifequal%}>500条</option>
<option value="1000" {%ifequal limit 1000%}selected="selected"{%endifequal%}>1000条</option>
</select>
<td width="60%">
<p align="center"><input type="submit" value="search" /></p>
</td>
</tr>
</table>
</form>
</fieldset>

{% if pl %}
    <p align="center"><b>
    total {{ total }} item{{ total|pluralize}}, {{ max_page }} page{{ max_page|pluralize}} .this is page {{ page }} from {{ item_from }}.
    {%ifnotequal total actual_total %}<font color="red">(actual should be {{actual_total}}. )</font>{%endifnotequal%}
    </b></p>

    <p align="right" >{% PostListUrlPages qs page max_page as pagelist%}&nbsp;&nbsp;&nbsp;</p>
    <table>
    <tr>
    <th width="3%">no</th>
    <th width="62%">title</th>
    <th width="3%">nr</th>
    <th width="9%">crt_date</th>
    <th width="9%">upd_date</th>
    <th width="14%">author</th>
    </tr>

    {% for item in pl %}
        <tr>
        <td align="center" ><a href="{%url post-url post_id=item.id page_from=1%}" >{{forloop.counter|add:item_from}} </a></td>
        <td>[{{item.sector.name}}]&nbsp;&nbsp;<a href="{% url post-url post_id=item.id page_from=1 %}">{{item.title}}</a></td>
        <td align="center"> {{ item.nr_reply }}</td>
        <td align="center" > {{ item.crt_date|date:"y-m-d H:i" }}</td>
        <td align="center"> {{ item.upd_date|date:"y-m-d H:i" }}</td>
        <td align="center"> {{item.author}} </td>
        </tr>
    {% endfor %}

    </table>

    <p align="right" >{% PostListUrlPages qs page max_page as pagelist%}&nbsp;&nbsp;&nbsp;</p>

{% else %}
    <p>No post are available.</p>
{% endif %}
<p align="center"><b><a href="{% url index %}">index</a></b></p>

{% endblock %}
